# encoding=utf-8
import os

from utils.kit_profile import Profile
from utils.kit_utils import Log, Function

from model.kit_data import cache


class SettingsProcesser:

    @classmethod
    def load_data(cls):
        Log.info("starting load local settings data")
        if not os.path.isfile(Profile.settings_file):
            Function.json_write(Profile.settings_file, {})
        settings_data, err = Function.json_read(Profile.settings_file)
        if settings_data is None:
            return None, err
        cache.init_settings_data(settings_data)

        Log.debug_switch = settings_data.get('log_debug_switch', False)
        return settings_data, err

